﻿using System;
using System.Diagnostics;
using System.Web.Mvc;
using System.Web.Routing;
using DAL;

namespace BlogWebSite
{
    public class MvcApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);
        }

        protected void Session_Start()
        {
            Session["Login"] = null;
        }

        protected void Application_Error()
        {
            int rowsAffected = DB.LogError(Server.GetLastError().Message, DateTime.Now);
            Debug.Print(string.Format("ErrorLogging. Rows affected: {0}", rowsAffected));
            //Response.Redirect("~/Controllers/ErrorController");
            //Server.Transfer("~/Error.cshtml");

            //Server.ClearError();//do not use as it blocks redirecting to error page
        }
    }
}
